#ifndef __AUDIO_DECODE_H__
#define __AUDIO_DECODE_H__

#include <map>
#include <mutex>
#include <functional>
#include "Pal/AudioDec.h"
#include "json.h"
#include "ConfigApi.h"

#include "Thread/Thread.h"


namespace Media{

class AudioDecode{
public:
	static AudioDecode *instance(int channel);

	bool getFormat(AudioDecFormat *format);

	bool setFormat(AudioDecFormat* format);

	bool start();

	bool stop();

	bool putPacket(AudioDecPacket *packet);

	bool setStreamDisplayChn(int channel);
	
private:
	AudioDecode(int channel);

	bool createDecoder();

	bool decodeInit();
	
private:
	static std::map<int, AudioDecode *> 	sm_decoderMap;

	static std::recursive_mutex 			sm_mapMutex;

	AudioDecFormat							m_format;
	
	AudioDecoder *							m_audioDecoder = nullptr;
	
	int 									m_channel = 0;
	
	bool									m_started = false; //start作为启动标志,避免多个业务多次启停

};

}//namespace Media
#endif


